package service.impl;


import bean.pojo.GdDoctor;
import bean.pojo.GdUserDoctorlist;
import dao.GdUserDoctorlistMapper;
import org.springframework.stereotype.Service;
import service.GdUserDoctorlistService;

import javax.annotation.Resource;
import java.util.List;

/**
*  @author author
*/
@Service
public class GdUserDoctorlistServiceImpl implements GdUserDoctorlistService {
    @Resource
    GdUserDoctorlistMapper gdUserDoctorlistMapper;

    /**
     * 查询用户关注的医生列表
     * @param userId
     * @return
     */
    @Override
    public List<GdDoctor> selectDocList(Long userId) throws Exception{
        return gdUserDoctorlistMapper.selectDocList(userId);
    }

    /**
     * 判断医生是否已在关注列表中
     * @return
     */
    public boolean isFollow(Long doctorId, Long userId){
        return gdUserDoctorlistMapper.isFollow(doctorId,userId)!=null;
    }

    /**
     * 添加关注
     * @param userId
     * @param doctorId
     * @return
     */
    @Override
    public boolean follow(Long userId, Long doctorId) throws Exception{
        return gdUserDoctorlistMapper.insert(userId,doctorId)>0;
    }

    /**
     * 取消关注
     * @param userId
     * @param doctorId
     * @return
     */
    @Override
    public boolean unFollow(Long userId, Long doctorId) throws Exception{
        return gdUserDoctorlistMapper.delete(userId,doctorId)>0;
    }
}